﻿using Microsoft.AspNetCore.Mvc;
using Swashbuckle.AspNetCore.Annotations;

namespace DDDDemo1;

[Controller]
[Route("api/app/payment")]
[SwaggerTag("支付")]
[Produces("application/json")]
public class PaymentController : Controller
{
    private IPaymentAppService _PaymentAppService;
    private ICurrentUser _CurrentUser;

    public PaymentController(
        IPaymentAppService paymentAppService,
        ICurrentUser currentUser)
    {
        _PaymentAppService = paymentAppService;
        _CurrentUser = currentUser;
    }

    [HttpPost]
    [Route("pay")]
    [SwaggerOperation("支付")]
    public async Task<PayResult> PayAsync([FromBody] PayParameter parameter)
        => await _PaymentAppService.PayAsync(
            _CurrentUser.Id,
            parameter.MerchantAccountNo,
            parameter.Amount);
}
